Abstract Animals collect sensory information from their environment and use it to select among the many behaviors they can perform. The exact neural circuits that enable them to detect, compare, and combine sensory stimuli across space and time to organize motor sequences remain unknown. Grooming behavior in Drosophila is a sensory-driven motor sequence. We propose to use optogenetic tools and behavioral analysis to identify the sensory neurons and circuits relevant for initiation and progression of the fly grooming sequence. Grooming is innate ? the basic capacity to groom is inborn, relying on genetically-specified neural connections, and therefore accessible to dissection by genetic screens. But the sequence of the actions that constitute grooming is flexible: there is a high probability that head sweeps and front leg rubs will occur early and that back leg subroutines to clean the posterior body parts will happen later, but the exact order of these movements is not fixed. Flies use updating sensory cues to modify the trajectory of leg sweeps, the duration of cleaning bouts, and the order of movements to remove different distributions of debris effectively. A deep mechanistic understanding of how the nervous system organizes reliable but adaptive motor sequences will address the larger questions of how animals make use of a flood of sensory data, how they balance the need to exercise a movement precisely with the need to modify it based on context, and how a limited number of neurons produce the diverse array of animal behaviors. Neural circuit motifs form the basic computational units of all nervous systems. Defining the circuits that accomplish sensory comparisons that control a motor sequence in a simpler system such as fly grooming will provide a template for understanding how similar functions are achieved in all brains.